class OliveProj_TouchBomb extends UTProjectile;

var transient bool bAttachedToMouse;
var transient bool bChangedToBomb;
var transient SkeletalMesh BombMesh;
var transient SkeletalMeshComponent BombMeshComponent;

simulated function HandleCollision( Actor Other, PrimitiveComponent OtherComp, vector HitLocation, vector HitNormal )
{
	//`log(self@"** hit!"@Other@OtherComp@HitNormal@HitLocation);
    if( Other != None  /*&& Physics == PHYS_Projectile*/ )
    {
        // a bit of a hack, massage data for pawns
        if ( (Pawn(Other) != None) && (SkeletalMeshComponent(OtherComp) != None) )
        {
            HitNormal = HitLocation - Other.Location;
            HitNormal.Z = 0.f;
            HitNormal = Normal(HitNormal);
        }
        Explode(HitLocation, HitNormal);
    }
}

simulated singular event Touch( Actor Other, PrimitiveComponent OtherComp, vector HitLocation, vector HitNormal )
{
	//`log(GetFuncName()@Other);
    // Ignore touches on fluid surface or physics volumes
    if(FluidSurfaceActor(Other) != None || PhysicsVolume(Other) != None)
    {
        return;
    }

	ImpactedActor = Other;
    HandleCollision( Other, OtherComp, HitLocation, HitNormal );
}

simulated function HitWall( vector HitNormal, Actor Wall, PrimitiveComponent WallComp )
{
    HandleCollision( Wall, WallComp, Location, HitNormal );
}
//state AttachedToMouse
//{
//	simulated function Tick(float DeltaTime)
//	{
//		super.Tick(DeltaTime);
//	}

//Begin:
//}

function ChangeToBomb()
{
	if(!bChangedToBomb)
	{
		if(BombMeshComponent == none)
		{
			BombMeshComponent = new(self) class'SkeletalMeshComponent';
		}
		BombMeshComponent.SetSkeletalMesh(BombMesh);
		//BombMeshComponent.SetScale(1);
		//AttachComponent(BombMeshComponent);
		ReattachComponent(BombMeshComponent);
		bChangedToBomb = true;
	}
}

DefaultProperties
{
	Begin Object Class=SkeletalMeshComponent Name=ESkeletalMeshComponent
		SkeletalMesh=SkeletalMesh'KismetGame_Assets.Anims.SK_Jazz'
		BlockRigidBody=TRUE
		bUpdateSkelWhenNotRendered=false
		Translation=(Z=0.0)
		Scale=0.2f
	End Object
	Components.Add(ESkeletalMeshComponent)
	bAttachedToMouse = false

	BombMesh = SkeletalMesh'KismetGame_Assets.Pickups.SK_CarrotJuice'
}
